package com.netease.xone.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.widget.FrameLayout;

import com.netease.pkgRelated.XoneConsts;
import com.netease.xone.R;
import com.netease.xone.fragment.FragmentInfoList;
import com.netease.xone.fragment.FragmentInfoList.InfoListType;

public class ActivityTopicInfoList extends ActivityX1Base{

    public static void startActivity(Context context, long topicId, String topicName){
        Intent i = new Intent(context, ActivityTopicInfoList.class);
        i.putExtra(XoneConsts.BUNDLE_KEY.TOPIC_ID, topicId);
        i.putExtra(XoneConsts.BUNDLE_KEY.TOPIC_NAME, topicName);
        context.startActivity(i);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        long topicId = getIntent().getLongExtra(XoneConsts.BUNDLE_KEY.TOPIC_ID, -1);
        String topicName = getIntent().getStringExtra(XoneConsts.BUNDLE_KEY.TOPIC_NAME);
        setTitle("#" + topicName + "#");
        FrameLayout frame = new FrameLayout(this);
        frame.setId(R.id.activity_topic_discuss_container_id);
        setContentView(frame);

        if (findViewById(R.id.activity_topic_discuss_container_id) != null && savedInstanceState == null) {
            FragmentInfoList f = FragmentInfoList.newInstance(InfoListType.topic_discuss, topicId);
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.replace(R.id.activity_topic_discuss_container_id, f);
            ft.commit();
        }
    }

}
